package Xiancheng;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class FormatMain
{
	public static void main(String[] args)
	{
		System.out.println("=======");
		DateFormat();
		NumberFormat();
	}

	private static void NumberFormat()
	{
		System.out.println("==pow=="+ Math.pow(2, 3));
		
	}

	private static void DateFormat()
	{
		String pattern = "yyyy-MM-dd";
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
		System.out.println(simpleDateFormat);
		String str = simpleDateFormat.format(new Date());
		System.out.println(str);
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		calendar.add(calendar.YEAR, -20);
		Date da = calendar.getTime();
		System.out.println(da.toLocaleString());
		String str1 = simpleDateFormat.format(da);
		System.out.println(str1);
		try
		{
			String str2 = "18-2-3 下午3:23";
//			Date da1 = simpleDateFormat.parse(str2);
			SimpleDateFormat aa = new SimpleDateFormat();
			Date da1 = aa.parse(str2);
			Calendar calendar1 = Calendar.getInstance();
			calendar1.setTime(da1);
			calendar1.add(calendar1.YEAR, -2);
			Date da2 = calendar1.getTime();
			System.out.println(da2.toLocaleString());
		} catch (ParseException e)
		{
			e.printStackTrace();
		}
	}
}
